<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	template="/WEB-INF/template/template.xhtml">

	<ui:define name="body">
		<style type="text/css">
p {
	margin-top: 5px !important;
	margin-bottom: 5px !important;
	padding-left: 5px !important;
}
</style>
<ui:debug hotkey="0" rendered="true"></ui:debug>
		<h:form id="frmPrincipal">
			<h:outputLabel value="ArtisId" for="id"></h:outputLabel>
			<br />
			<h:inputText id="artistNameValue" value="#{artistBean.artistNameValue}"></h:inputText>
			<a4j:commandButton action="#{artistBean.findArtistByName()}"
				value="Find Artist" render="artistDetail"></a4j:commandButton>
			<br />
			<br />
			<h:inputText id="id" value="#{artistBean.id}"></h:inputText>
			<a4j:commandButton action="#{artistBean.findArtist()}"
				value="Find Artist" render="artistDetail"></a4j:commandButton>
			<br />
			<h:inputText id="artistStartList"
				value="#{artistBean.artistStartList}"></h:inputText>
			<a4j:commandButton action="#{artistBean.findAll()}" value="Find All"
				render="artistsResults"></a4j:commandButton>
			<rich:panel id="artistDetail">
				<rich:panel id="artistPanelResult">
					<h:outputLabel value="#{messages.artist_name}"></h:outputLabel>
					<br />
					<h:outputLink value="https://www.google.com.br/search"
						target="_blank">
						<f:param name="q" value="#{artistBean.artistName.name}" />
						<h:outputText value="#{artistBean.artistName.name}">
						</h:outputText>
					</h:outputLink>
				</rich:panel>
				<rich:panel id="artistsResults">
					<rich:panel id="reportExport" rendered="#{not empty artistBean.artists}">
						<h:commandLink action="#{artistBean.exportSearchResult()}" target="blank" value="Export Result" ></h:commandLink>
					</rich:panel>
					<rich:dataTable id="artists" var="artist" rows="20"
						value="#{artistBean.artists}"
						onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
						onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
						rendered="#{not empty artistBean.artists}">
						<rich:column>
							<f:facet name="header">Artist Name</f:facet>
							<h:outputLink value="https://www.google.com.br/search"
								target="_blank">
								<f:param name="q" value="#{artist.name}" />
								<h:outputText value="#{artist.name}" />
							</h:outputLink>
						</rich:column>
						<rich:column>
							<f:facet name="header">Credits</f:facet>
							<a4j:commandLink action="#{artistBean.artistCreditBean.findArtistCredits()}"
								render="credit_list_#{artist.id} , releases_#{artist.id}" execute="@this">
								<a4j:param value="#{artist.id}"
									assignTo="#{artistBean.artistCreditBean.artistId}"></a4j:param>
								<h:outputText value="+" />
							</a4j:commandLink>
							<rich:panel id="credit_list_#{artist.id}">
								<rich:panel id="artistCreditResults"
									rendered="#{not empty artistBean.artistCreditBean.artistCredits}">
									<rich:dataTable id="artistCreditsTable" var="credit" rows="20"
										value="#{artistBean.artistCreditBean.artistCredits}"
										onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
										onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
										rendered="#{not empty artistBean.artistCreditBean.artistCredits}">
										<rich:column>
											<f:facet name="header">Credits</f:facet>
											<h:outputLink value="https://www.google.com.br/search"
												target="_blank">
												<f:param name="q" value="#{credit.name}" />
												<h:outputText value="#{credit.name}" />
											</h:outputLink>
										</rich:column>
									</rich:dataTable>
								</rich:panel>
							</rich:panel>
						</rich:column>
						<rich:column>
							<f:facet name="header">Releases</f:facet>
							<t:div id="releases_#{artist.id}">
								<a4j:region
									rendered="#{not empty artistBean.artistCreditBean.artistCredits}">
									<a4j:commandLink action="#{artistBean.releaseBean.findReleases()}"
										render="releaseSearchResult" execute="@this">
										<h:outputText value="Find Releases" />
										<a4j:param value="#{artistBean.artistCreditBean.getJsonIds()}" assignTo="#{artistBean.releaseBean.artistCredits}"></a4j:param>
									</a4j:commandLink>
								</a4j:region>
							</t:div>
							<t:div id="releaseSearchResult">
								<rich:dataTable id="releaseList" var="release" rows="20"
									value="#{artistBean.releaseBean.releases}"
									onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
									onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
									rendered="#{not empty artistBean.releaseBean.releases}">
									<rich:column>
										<f:facet name="header">Release Name</f:facet>
										<h:outputLink value="https://www.google.com.br/search"
											target="_blank">
											<f:param name="q" value="#{release.name}" />
											<h:outputText value="#{release.name}" />
										</h:outputLink>
									</rich:column>
								</rich:dataTable>
									<rich:dataScroller align="left" for="releaseList" maxPages="20"
										page="1" id="sc3" rendered="#{not empty releaseBean.releases}" />
							</t:div>
						</rich:column>
					</rich:dataTable>
					<rich:dataScroller align="left" for="artists" maxPages="20"
						page="1" id="sc2" />
				</rich:panel>
			</rich:panel>
		</h:form>
	</ui:define>
</ui:composition>